// JavaScript Document
var key="";

//更换验证码
function changeKey() {
	key="";
	//验证码产生的数组
	var k=new Array(
		"0","1","2","3","4","5","6","7","8","9",
		"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
		"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"
	);
	for(var i=0;i<4;i++) {	//循环4次  
		var index=Math.floor(62*Math.random());	//得到4个随机数
		key+=k[index];		//拼接得到一个4位的验证码
	}
	document.getElementById("changeKey").text=key;	//将验证码在页面上显示
}

function checkInfo(){
	var inputkey=document.getElementById("key").value;	
	if(inputkey.toUpperCase()!=key.toUpperCase()) {
		alert("验证码错误...");
		return;
	}else{
		$.post("loginServlet?op=adminLogin",$("#loginform").serialize(),function(data){
			console.info(data.rows);
			if(data.rows!=null){
				location.href="back/index.jsp";
			}else{
				alert("用户名或密码错误...");
			}
		},"json");
	}
}

window.onload=changeKey;